{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Date and time features with Feature-engine"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from feature_engine.datetime import DatetimeFeatures"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2024-05-17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2024-05-18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2024-05-19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2024-05-20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2024-05-21</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        date\n",
       "0 2024-05-17\n",
       "1 2024-05-18\n",
       "2 2024-05-19\n",
       "3 2024-05-20\n",
       "4 2024-05-21"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# let's create a toy dataframe with some date variables\n",
    "\n",
    "# first we create a series with the ranges\n",
    "rng_ = pd.date_range(\"2024-05-17\", periods=20, freq=\"D\")\n",
    "\n",
    "# now we convert the series in a dataframe\n",
    "data = pd.DataFrame({\"date\": rng_})\n",
    "\n",
    "# output the first 5 rows\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Extract all possible features\n",
    "\n",
    "dtfs = DatetimeFeatures(\n",
    "    variables=None,  # it identifies the datetime variable automatically.\n",
    "    features_to_extract=\"all\",\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date_month</th>\n",
       "      <th>date_quarter</th>\n",
       "      <th>date_semester</th>\n",
       "      <th>date_year</th>\n",
       "      <th>date_week</th>\n",
       "      <th>date_day_of_week</th>\n",
       "      <th>date_day_of_month</th>\n",
       "      <th>date_day_of_year</th>\n",
       "      <th>date_weekend</th>\n",
       "      <th>date_month_start</th>\n",
       "      <th>date_month_end</th>\n",
       "      <th>date_quarter_start</th>\n",
       "      <th>date_quarter_end</th>\n",
       "      <th>date_year_start</th>\n",
       "      <th>date_year_end</th>\n",
       "      <th>date_leap_year</th>\n",
       "      <th>date_days_in_month</th>\n",
       "      <th>date_hour</th>\n",
       "      <th>date_minute</th>\n",
       "      <th>date_second</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>2024</td>\n",
       "      <td>20</td>\n",
       "      <td>4</td>\n",
       "      <td>17</td>\n",
       "      <td>138</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>31</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>2024</td>\n",
       "      <td>20</td>\n",
       "      <td>5</td>\n",
       "      <td>18</td>\n",
       "      <td>139</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>31</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>2024</td>\n",
       "      <td>20</td>\n",
       "      <td>6</td>\n",
       "      <td>19</td>\n",
       "      <td>140</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>31</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>2024</td>\n",
       "      <td>21</td>\n",
       "      <td>0</td>\n",
       "      <td>20</td>\n",
       "      <td>141</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>31</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>2024</td>\n",
       "      <td>21</td>\n",
       "      <td>1</td>\n",
       "      <td>21</td>\n",
       "      <td>142</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>31</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   date_month  date_quarter  date_semester  date_year  date_week  \\\n",
       "0           5             2              1       2024         20   \n",
       "1           5             2              1       2024         20   \n",
       "2           5             2              1       2024         20   \n",
       "3           5             2              1       2024         21   \n",
       "4           5             2              1       2024         21   \n",
       "\n",
       "   date_day_of_week  date_day_of_month  date_day_of_year  date_weekend  \\\n",
       "0                 4                 17               138             0   \n",
       "1                 5                 18               139             1   \n",
       "2                 6                 19               140             1   \n",
       "3                 0                 20               141             0   \n",
       "4                 1                 21               142             0   \n",
       "\n",
       "   date_month_start  date_month_end  date_quarter_start  date_quarter_end  \\\n",
       "0                 0               0                   0                 0   \n",
       "1                 0               0                   0                 0   \n",
       "2                 0               0                   0                 0   \n",
       "3                 0               0                   0                 0   \n",
       "4                 0               0                   0                 0   \n",
       "\n",
       "   date_year_start  date_year_end  date_leap_year  date_days_in_month  \\\n",
       "0                0              0               1                  31   \n",
       "1                0              0               1                  31   \n",
       "2                0              0               1                  31   \n",
       "3                0              0               1                  31   \n",
       "4                0              0               1                  31   \n",
       "\n",
       "   date_hour  date_minute  date_second  \n",
       "0          0            0            0  \n",
       "1          0            0            0  \n",
       "2          0            0            0  \n",
       "3          0            0            0  \n",
       "4          0            0            0  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Extract features.\n",
    "dft = dtfs.fit_transform(data)\n",
    "\n",
    "# Capture the names of the features we just created.\n",
    "# (Feature-engine tags them with the original variable name\n",
    "# plus the feature it extracted).\n",
    "vars_ = [v for v in dft.columns if \"date\" in v]\n",
    "\n",
    "# Show\n",
    "dft[vars_].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['date_month',\n",
       " 'date_quarter',\n",
       " 'date_semester',\n",
       " 'date_year',\n",
       " 'date_week',\n",
       " 'date_day_of_week',\n",
       " 'date_day_of_month',\n",
       " 'date_day_of_year',\n",
       " 'date_weekend',\n",
       " 'date_month_start',\n",
       " 'date_month_end',\n",
       " 'date_quarter_start',\n",
       " 'date_quarter_end',\n",
       " 'date_year_start',\n",
       " 'date_year_end',\n",
       " 'date_leap_year',\n",
       " 'date_days_in_month',\n",
       " 'date_hour',\n",
       " 'date_minute',\n",
       " 'date_second']"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vars_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['date']"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# The datetime variable, which was automatically\n",
    "# identified, is stored in an attribute.\n",
    "\n",
    "dtfs.variables_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Extract most common features\n",
    "\n",
    "dtfs = DatetimeFeatures(\n",
    "    variables=None,  # it identifies the datetime variable automatically\n",
    "    features_to_extract=None,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date_month</th>\n",
       "      <th>date_year</th>\n",
       "      <th>date_day_of_week</th>\n",
       "      <th>date_day_of_month</th>\n",
       "      <th>date_hour</th>\n",
       "      <th>date_minute</th>\n",
       "      <th>date_second</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5</td>\n",
       "      <td>2024</td>\n",
       "      <td>4</td>\n",
       "      <td>17</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5</td>\n",
       "      <td>2024</td>\n",
       "      <td>5</td>\n",
       "      <td>18</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5</td>\n",
       "      <td>2024</td>\n",
       "      <td>6</td>\n",
       "      <td>19</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>2024</td>\n",
       "      <td>0</td>\n",
       "      <td>20</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>2024</td>\n",
       "      <td>1</td>\n",
       "      <td>21</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   date_month  date_year  date_day_of_week  date_day_of_month  date_hour  \\\n",
       "0           5       2024                 4                 17          0   \n",
       "1           5       2024                 5                 18          0   \n",
       "2           5       2024                 6                 19          0   \n",
       "3           5       2024                 0                 20          0   \n",
       "4           5       2024                 1                 21          0   \n",
       "\n",
       "   date_minute  date_second  \n",
       "0            0            0  \n",
       "1            0            0  \n",
       "2            0            0  \n",
       "3            0            0  \n",
       "4            0            0  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Extract features\n",
    "dft = dtfs.fit_transform(data)\n",
    "\n",
    "# Capture the names of the features we just created.\n",
    "# (Feature-engine tags them with the original variable name\n",
    "# plus the feature it extracted).\n",
    "vars_ = [v for v in dft.columns if \"date\" in v]\n",
    "\n",
    "# Show\n",
    "dft[vars_].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Extract user defined features\n",
    "\n",
    "dtfs = DatetimeFeatures(\n",
    "    variables=None,  # it identifies the datetime variable automatically\n",
    "    features_to_extract=[\"week\", \"year\", \"day_of_month\", \"day_of_week\"],\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date_week</th>\n",
       "      <th>date_year</th>\n",
       "      <th>date_day_of_month</th>\n",
       "      <th>date_day_of_week</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>20</td>\n",
       "      <td>2024</td>\n",
       "      <td>17</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>20</td>\n",
       "      <td>2024</td>\n",
       "      <td>18</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>20</td>\n",
       "      <td>2024</td>\n",
       "      <td>19</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>21</td>\n",
       "      <td>2024</td>\n",
       "      <td>20</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>21</td>\n",
       "      <td>2024</td>\n",
       "      <td>21</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   date_week  date_year  date_day_of_month  date_day_of_week\n",
       "0         20       2024                 17                 4\n",
       "1         20       2024                 18                 5\n",
       "2         20       2024                 19                 6\n",
       "3         21       2024                 20                 0\n",
       "4         21       2024                 21                 1"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Extract features\n",
    "dft = dtfs.fit_transform(data)\n",
    "\n",
    "# Capture the names of the features we just created.\n",
    "# (Feature-engine tags them with the original variable name\n",
    "# plus the feature it extracted).\n",
    "vars_ = [v for v in dft.columns if \"date\" in v]\n",
    "\n",
    "# Show\n",
    "dft[vars_].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2024-08-01 09:00:00+02:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2024-08-01 10:00:00+02:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2024-08-01 11:00:00+02:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2024-08-01 09:00:00-05:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2024-08-01 10:00:00-05:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2024-08-01 11:00:00-05:00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                        time\n",
       "0  2024-08-01 09:00:00+02:00\n",
       "1  2024-08-01 10:00:00+02:00\n",
       "2  2024-08-01 11:00:00+02:00\n",
       "0  2024-08-01 09:00:00-05:00\n",
       "1  2024-08-01 10:00:00-05:00\n",
       "2  2024-08-01 11:00:00-05:00"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# First, let's create a toy dataframe with some\n",
    "# timestamps in different time zones.\n",
    "\n",
    "df = pd.DataFrame()\n",
    "\n",
    "df[\"time\"] = pd.concat(\n",
    "    [\n",
    "        pd.Series(\n",
    "            pd.date_range(\n",
    "                start=\"2024-08-01 09:00\", freq=\"h\", periods=3, tz=\"Europe/Berlin\"\n",
    "            )\n",
    "        ),\n",
    "        pd.Series(\n",
    "            pd.date_range(\n",
    "                start=\"2024-08-01 09:00\", freq=\"h\", periods=3, tz=\"US/Central\"\n",
    "            )\n",
    "        ),\n",
    "    ],\n",
    "    axis=0,\n",
    ")\n",
    "\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can see the different timezones indicated by the +2 and -5, with respect to the central meridian."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "dfts = DatetimeFeatures(\n",
    "    features_to_extract=[\"day_of_week\", \"hour\", \"minute\"],\n",
    "    drop_original=False,\n",
    "    utc=True,  # to handle timezones\n",
    ")\n",
    "\n",
    "# DatetimeFeatures will take all timestamps to utc\n",
    "# before deriving the features."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>time</th>\n",
       "      <th>time_day_of_week</th>\n",
       "      <th>time_hour</th>\n",
       "      <th>time_minute</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2024-08-01 09:00:00+02:00</td>\n",
       "      <td>3</td>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2024-08-01 10:00:00+02:00</td>\n",
       "      <td>3</td>\n",
       "      <td>8</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2024-08-01 11:00:00+02:00</td>\n",
       "      <td>3</td>\n",
       "      <td>9</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2024-08-01 09:00:00-05:00</td>\n",
       "      <td>3</td>\n",
       "      <td>14</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2024-08-01 10:00:00-05:00</td>\n",
       "      <td>3</td>\n",
       "      <td>15</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                        time  time_day_of_week  time_hour  time_minute\n",
       "0  2024-08-01 09:00:00+02:00                 3          7            0\n",
       "1  2024-08-01 10:00:00+02:00                 3          8            0\n",
       "2  2024-08-01 11:00:00+02:00                 3          9            0\n",
       "0  2024-08-01 09:00:00-05:00                 3         14            0\n",
       "1  2024-08-01 10:00:00-05:00                 3         15            0"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dft = dfts.fit_transform(df)\n",
    "\n",
    "dft.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "fsml",
   "language": "python",
   "name": "fsml"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": "block",
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
